package com.disruptor.sample._04clear.run;

import com.disruptor.sample._04clear.consumer.ClearingEventHandler;
import com.disruptor.sample.common.dto.ObjectEvent;
import com.lmax.disruptor.dsl.Disruptor;
import com.lmax.disruptor.util.DaemonThreadFactory;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class ClearingEventMain {

  public static void main(String[] args) {
    int bufferSize = 1024;

    Disruptor<ObjectEvent<String>> disruptor = new Disruptor<>(
        () -> new ObjectEvent<>(), bufferSize, DaemonThreadFactory.INSTANCE);

    disruptor
        .handleEventsWith((event, sequence, endOfBatch) -> log.info("event = {}", event))
        .then(new ClearingEventHandler());
  }

}
